package fr.utbm.gl52.smartgrid.model.load;

import java.util.Map;
import java.util.TreeMap;

import fr.utbm.gl52.smartgrid.model.device.Device;
import fr.utbm.gl52.smartgrid.model.device.Messages;
import fr.utbm.gl52.smartgrid.util.Constants;
import fr.utbm.gl52.smartgrid.util.properties.Properties;

public abstract class Load extends Device {

	//
	public Load() {
		super();
	}

	public Load(String name, double pwr, double current, double voltage) {
		super(name, pwr, current, voltage, 1);

	}

	public Map<String, Properties<?>> getProperties() {
		TreeMap<String, Properties<?>> properties = new TreeMap<String, Properties<?>>();
		properties = (TreeMap<String, Properties<?>>) super.getProperties();
		properties.remove(Messages.getString("Device.5")); //$NON-NLS-1$
		return properties;
	}

	public void setProperties(Map<String, Properties<?>> map) {
		this.name = (String) map.remove(Messages.getString("Device.1")).getValue(); //$NON-NLS-1$
		this.power = (Double) map.remove(Messages.getString("Device.2")).getValue(); //$NON-NLS-1$
		this.current = (Double) map
				.remove(Messages.getString("Device.3")).getValue(); //$NON-NLS-1$
		this.voltage = (Double) map
				.remove(Messages.getString("Device.4")).getValue(); //$NON-NLS-1$
		if (map.size() != 0) {
			if (Constants.isDebug)
				System.out
						.println(Messages.getString("Device.6") + map.size()); //$NON-NLS-1$
		}

	}
}
